Skip to content

Conversation

@ArgoZhang
Copy link
Member

@ArgoZhang ArgoZhang commented May 7, 2025

Link issues

fixes #5982

Summary By Copilot

This pull request introduces a new extension method for the DialogService class to simplify showing dialogs with a specified component and title. Additionally, corresponding unit tests have been added to ensure the new functionality works as expected.

New Feature: DialogService Extension Method

  • Added a Show<TComponent> extension method to the DialogService class in DialogServiceExtensions.cs. This method allows displaying a dialog with a specified component (TComponent), title, and optional parameters, streamlining dialog creation.

Unit Tests for New Method

  • Added unit tests in DialogTest.cs to verify the functionality of the new Show<TComponent> method, including invoking the dialog with a title and ensuring correct behavior during dialog closure.

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

Verification

  • Manual (required)
  • Automated

Packaging changes reviewed?

  • Yes
  • No
  • N/A

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Add a generic Show<TComponent> extension method to the DialogService to simplify dialog creation with a specified component and title

New Features:

  • Introduced a generic Show<TComponent> extension method for DialogService that allows displaying a dialog with a specified component and title

Tests:

  • Added unit test for the new Show<TComponent> extension method to verify its functionality

@ArgoZhang ArgoZhang requested a review from Copilot May 7, 2025 02:27
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 7, 2025

Reviewer's Guide

This pull request enhances the DialogService by introducing a new generic extension method, Show<TComponent>. This method simplifies dialog display by internally constructing a DialogOption object, setting its Title from the provided argument and creating the Component using BootstrapDynamicComponent.CreateComponent<TComponent>() with optional parameters. The ShowFooter option for the dialog is defaulted to false. The actual display logic is then delegated to the existing DialogService.Show() method.

Sequence Diagram: Dialog Creation with Show Extension Method

sequenceDiagram
    participant C as Client
    participant DSE as DialogServiceExtensions
    participant DO as DialogOption
    participant BDC as BootstrapDynamicComponent
    participant DS as DialogService

    C->>DSE: Call Show<TComponent>(title, parameters, dialog) on DialogService instance
    activate DSE
    DSE->>DO: new DialogOption()
    activate DO
    DO-->>DSE: option
    deactivate DO
    DSE->>DO: option.Title = title
    DSE->>DO: option.ShowFooter = false
    DSE->>BDC: CreateComponent<TComponent>(parameters)
    activate BDC
    BDC-->>DSE: component
    deactivate BDC
    DSE->>DO: option.Component = component
    DSE->>DS: Show(option, dialog)
    activate DS
    DS-->>DSE: Task
    deactivate DS
    DSE-->>C: Task
    deactivate DSE
Loading

File-Level Changes

Change Details Files
Introduced a Show<TComponent> extension method to DialogService for streamlined dialog creation and display.
  • Defined the new public static extension method Show<TComponent>.
  • The method accepts DialogService service, string title, optional parameters, and an optional Dialog instance.
  • A DialogOption instance is created; its Title is set if a title is provided.
  • The DialogOption.Component is populated using BootstrapDynamicComponent.CreateComponent<TComponent>(parameters).
  • DialogOption.ShowFooter is set to false by default.
  • The method calls the existing service.Show(option, dialog) to render the dialog.
src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs
Added unit tests to verify the new Show<TComponent> extension method.
  • Implemented tests within a new region specific to the show extensions method.
  • Verified that dialog.Show<MockValidateFormDialog>("Test Title") correctly invokes the dialog.
  • Ensured the dialog closure mechanism (modal.Instance.CloseCallback()) functions as expected after using the new method.
test/UnitTest/Components/DialogTest.cs

Assessment against linked issues

Issue Objective Addressed Explanation
#5982 Add a Show<TComponent> extension method to the DialogService class.
#5982 The new method should allow displaying a dialog with a specified component (TComponent), title, and optional parameters.
#5982 Add unit tests to verify the functionality of the new Show<TComponent> method.

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@bb-auto bb-auto bot added the enhancement New feature or request label May 7, 2025
@bb-auto bb-auto bot added this to the v9.6.0 milestone May 7, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a generic Show extension method to DialogService to streamline dialog creation with a specified component and title, along with accompanying unit tests.

  • Introduces the Show extension method in DialogServiceExtensions.cs
  • Adds new unit tests in DialogTest.cs to validate the method’s behavior

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
test/UnitTest/Components/DialogTest.cs Adds test cases for the new extension method
src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs Implements the Show extension method with dialog option settings
Comments suppressed due to low confidence (1)

test/UnitTest/Components/DialogTest.cs:578

  • [nitpick] Consider adding assertions after the Show call to verify that the dialog displays the correct title, enhancing the test coverage of this new functionality.
await cut.InvokeAsync(() => dialog.Show<MockValidateFormDialog>("Test Title"));

sourcery-ai[bot]
sourcery-ai bot previously approved these changes May 7, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ArgoZhang - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@codecov
Copy link

codecov bot commented May 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (384fd9d) to head (6347075).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5983   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          670       670           
  Lines        30606     30616   +10     
  Branches      4352      4353    +1     
=========================================
+ Hits         30606     30616   +10     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ArgoZhang ArgoZhang requested a review from Copilot May 7, 2025 02:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new generic extension method, Show, to the DialogService to simplify dialog creation, along with unit tests validating its behavior.

  • Introduces the Show extension method in DialogServiceExtensions.cs.
  • Adds unit tests in DialogTest.cs to verify the new method.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/UnitTest/Components/DialogTest.cs Adds tests invoking the new Show extension method.
src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs Implements the new Show method with updated doc comments.
Files not reviewed (1)
  • src/BootstrapBlazor/BootstrapBlazor.csproj: Language not supported

@ArgoZhang ArgoZhang requested a review from Copilot May 7, 2025 03:01
@ArgoZhang
Copy link
Member Author

@sourcery-ai review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new generic extension method Show for the DialogService to simplify displaying dialogs with a specified component and title, along with added unit tests verifying its behavior.

  • Added Show extension method in DialogServiceExtensions.cs to configure and display dialogs.
  • Created unit tests in DialogTest.cs to ensure the new extension method triggers dialog display and closure correctly.

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
test/UnitTest/Components/DialogTest.cs Added tests under "Show Extensions Method" region to verify the new extension method.
src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs Introduced the Show extension method with proper configuration of dialog options.
Files not reviewed (1)
  • src/BootstrapBlazor/BootstrapBlazor.csproj: Language not supported
Comments suppressed due to low confidence (1)

src/BootstrapBlazor/Extensions/DialogServiceExtensions.cs:30

  • [nitpick] Review that the BootstrapDynamicComponent.CreateComponent method properly applies the provided parameters to the component; ensuring its behavior is consistent with dialog initializations elsewhere.
option.Component = BootstrapDynamicComponent.CreateComponent<TComponent>(parameters);

@ArgoZhang ArgoZhang merged commit 8addd2b into main May 7, 2025
5 checks passed
@ArgoZhang ArgoZhang deleted the refactor-dialog branch May 7, 2025 03:04
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ArgoZhang - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ArgoZhang ArgoZhang restored the refactor-dialog branch May 7, 2025 09:45
@ArgoZhang ArgoZhang deleted the refactor-dialog branch May 7, 2025 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(Dialog): add Show<TComponent> extension method

2 participants